/**
* Created by wl
* 基金储备库-管理团队信息
*/
<template>
    <div class="ca-p-20">
        <div v-if="!showEdit">
            <div class="ca-title">
                <el-button type="text"  class="ca-edit-btn el-icon-edit ca-right" @click="showEdit = true" :disabled="!isAuthEditPre" v-if="$route.name.includes('pre-investment-funds')">编辑</el-button>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-right" @click="showEdit=true" :disabled="!isAuthEdit" v-else>编辑</el-button>
            </div>
            <el-table
                :data='itemInfo.fundData'
                class="ca-table table_p_01 el-wid-100">
                <el-table-column
                    label="姓名"
                    prop="userName">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.userName" placement="top" v-if="scope.row.userName">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.userName}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    label="性别"
                    prop="sex">
                    <template slot-scope="scope">
                        {{scope.row.sex == 0 ? '男' : '女' }}
                    </template>
                </el-table-column>
                <el-table-column
                    label="出生年月"
                    prop="birthday">
                    <template slot-scope="scope">
                        {{scope.row.birthday == null ? '' : $moment(scope.row.birthday).format('YYYY-MM-DD')}}
                    </template>
                </el-table-column>
                <el-table-column
                    label="公司职务"
                    prop="duties">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.duties" placement="top" v-if="scope.row.duties">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.duties}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    label="学历"
                    prop="education">
                    <template slot-scope="scope">
                        {{scope.row.education | getNameById('education')}}
                    </template>
                </el-table-column>
                <el-table-column
                    label="专业"
                    prop="major">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.major" placement="top" v-if="scope.row.major">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.major}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="school"
                    label="毕业院校"
                    align="center">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.school" placement="top" v-if="scope.row.school">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.school}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="jobTime"
                    label="在职时间"
                    align="center">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.jobTime" placement="top" v-if="scope.row.jobTime">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.jobTime}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="role"
                    label="团队内角色"
                    align="center">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.role" placement="top" v-if="scope.row.role">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.role}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="fundList"
                    label="在管基金数量"
                    align="center">
                    <template slot-scope="scope">
                        <el-button type="text" @click="showDialog(scope.row.fundList)">{{scope.row.fundList.length}}</el-button>
                    </template>
                </el-table-column>
                <el-table-column
                    label="备注"
                    prop="remarks">
                    <template slot-scope="scope">
                        <el-tooltip effect="dark" :content="scope.row.remarks" placement="top" v-if="scope.row.remarks">
                            <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.remarks}}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>
            </el-table>
            <el-dialog
                title="在管基金"
                :visible.sync="dialogVisible"
                width="80%">
                <el-table
                    :data='fundList'
                    class="ca-table table_p_01 el-wid-100"
                    >
                    <el-table-column
                        label="基金名称"
                        prop="fundName"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.fundName" placement="top" v-if="scope.row.fundName">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.fundName}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="注册地"
                        prop="address"
                        width="120px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.address" placement="top" v-if="scope.row.address">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.address}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="scale"
                        label="基金规模</br>（万元）"
                        :render-header="renderTitle"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="paid"
                        label="实缴资本</br>（万元）"
                        :render-header="renderTitle"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        label="投资领域"
                        prop="field"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.field" placement="top" v-if="scope.row.field">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.field}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="投资阶段"
                        prop="stage"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.stage" placement="top" v-if="scope.row.stage">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.stage}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="investmentNumber"
                        label="投资项目数量"
                        align="center"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.investmentNumber" placement="top" v-if="scope.row.investmentNumber">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.investmentNumber}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="investmentMoney"
                        label="投资金额</br>（万元）"
                        :render-header="renderTitle"
                        align="center"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.investmentMoney" placement="top" v-if="scope.row.investmentMoney">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.investmentMoney}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="exitNumber"
                        label="退出项目数量"
                        align="center"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.exitNumber" placement="top" v-if="scope.row.exitNumber">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.exitNumber}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="exitMoney"
                        label="退出金额</br>（万元）"
                        :render-header="renderTitle"
                        align="center"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.exitMoney" placement="top" v-if="scope.row.exitMoney">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.exitMoney}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="irr"
                        label="irr"
                        align="center"
                        width="100px">
                        <template slot-scope="scope">
                            <el-tooltip effect="dark" :content="scope.row.irr" placement="top" v-if="scope.row.irr">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.irr}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="备注"
                        prop="remarks"
                        width="130px">
                        <template slot-scope="scope">
                            <el-tooltip class="item" effect="dark" :content="scope.row.remarks" placement="top" v-if="scope.row.remarks">
                                <el-button type="text" class="ca-notes ca-text-over-flow-ellipsis">{{scope.row.remarks}}</el-button>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                </el-table>
            </el-dialog>
        </div>
        <csFundInfo v-else @close="showEdit = false" @update="update"></csFundInfo>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                showEdit: false,
                isAuthEdit: isNoAuth('基金储备库-基金详情-编辑'),
                isAuthEditPre: isNoAuth('拟投资基金-基金详情-编辑'),
                dialogVisible: false,
                itemInfo: {
                    fundData: []
                },
                fundList: [], //在管基金
            }
        },
        created() {
        },
        mounted() {
            this.getInfo()
        },
        props: {
        },
        watch: {
        },
        methods: {
            async update() {
                this.showEdit = false
                await this.getInfo()
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 0, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 4, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            getInfo() {
                apiHttp(api.CHECK_TEAMINFO, {id: this.$route.params.itemId}).then(ret=> {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        this.itemInfo.fundData = ret.data
                    }
                })
            },
            showDialog(fundList) {
                this.dialogVisible = true
                this.fundList = fundList
            },
        },
        components: {
            'csFundInfo': require('./edit'),//基金信息edit页
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.ca-right {
    float: right;
}
.ca-table th {
    line-height: 20px;
}
.ca-notes {
    color: #666;
}
</style>